package com.ssyt.yt1.day19.generic;

/**
 * 泛型 + 标识接口
 * 
 * @author Administrator
 *
 */
public class GenericDemo6 {

	public static void main(String[] args) {
		// Student<BaseInfo> student = new Student<>();
		// BaseInfo baseInfo = new BaseInfo();
		// baseInfo.setName("元芳");
		// baseInfo.setAge(18);
		// student.setInfo(baseInfo);
		// System.out.println(student);

		Student<Info> student = new Student<>();
		BaseInfo baseInfo = new BaseInfo();
		baseInfo.setName("元芳");
		baseInfo.setAge(18);
		student.setInfo(baseInfo);
		System.out.println(student);
	}
}

interface Info {

}

class BaseInfo implements Info {

	private String name;
	private int age;

	public BaseInfo() {
		super();
	}

	public BaseInfo(String name, int age) {
		super();
		this.name = name;
		this.age = age;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	@Override
	public String toString() {
		return "BaseInfo [name=" + name + ", age=" + age + "]";
	}

}

class AddressInfo implements Info {

	private String province;
	private String city;

	public AddressInfo() {
		super();
	}

	public AddressInfo(String province, String city) {
		super();
		this.province = province;
		this.city = city;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	@Override
	public String toString() {
		return "AddressInfo [province=" + province + ", city=" + city + "]";
	}

}

class Student<T extends Info> {

	private T info;

	public Student() {
		super();
	}

	public Student(T info) {
		super();
		this.info = info;
	}

	public T getInfo() {
		return info;
	}

	public void setInfo(T info) {
		this.info = info;
	}

	@Override
	public String toString() {
		return "Student [info=" + info + "]";
	}

}
